<h1>Results for exam <%= @exam.title %> for <%=h @result.user.last_name %></h1>
<% @exam.questions.each do |q| %>
	<p>
		<h2>Question: </h2><%=h parse_images q.text%><br/>
		<h2>Score: </h2><%=h q.score %><br/>
		<h2>Type: </h2><%= 
			if q.checkbox == 0
				"checkbox"
			else
				"radiobutton"
			end
		%>
		<p>
			<h2>Answers: </h2><br/>
			<% q.answers.each do |a| %>
				<%=h parse_images a.text %> - <%= 
					tmp = "wrong"
					tmp = "correct" if a.correctness == 1 
					tmp
				%><br/>
				<h2><%=h @result.user.last_name%>'s answer is: </h2>
				<%= 
					tmp = nil
					@user_answers.each do |ua|
						if ua.answer == a
							tmp = ua
						end
					end
					if(!tmp.nil?)
						if(tmp.correctness == a.correctness)
							"<span class=\"correct_answer\">correct</span>"
						else
							"<span class=\"incorrect_answer\">wrong</span>"
						end
					else
						"error"
					end
				%> <br/>
			<% end %>
		</p>
	</p>
<% end %>
<p>
	<%=h @result.user.last_name %> reached <%=h @result.score %> scores of 
	<%=h @result.max_score %> scores and has a <%=h get_grade(@result) %>
</p>

<%= link_to 'Back', :action => 'list' %>
	